package com.ntschy.bt.service.impl;

import cn.hutool.core.util.IdUtil;
import com.ntschy.bt.entity.dataobject.BtSupplyShop;
import com.ntschy.bt.mapper.BtSupplyShopMapper;
import com.ntschy.bt.service.IBtSupplyShopService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;

/**
 * <p>
 * 供需超市 服务实现类
 * </p>
 *
 * @author cm
 * @since 2020-12-28
 */
@Service
public class BtSupplyShopServiceImpl implements IBtSupplyShopService {

    @Autowired
    private BtSupplyShopMapper supplyShopMapper;

    // * ================================================基础增删改查BEGIN============================================= *
    /**
     * 分页查询用户
     * 当前查询条件：根据用户名｜用户类别查询 时间倒序
     * @param supplyShop 用户对象
     * @return 用户列表
     */
    @Override
//    @ListDataScope(mainAlias = "u", mainField = "CreateSupplyShopID")
    public List<BtSupplyShop> pageSupplyShop(BtSupplyShop supplyShop) {
        return supplyShopMapper.pageSupplyShop(supplyShop);
    }

    /**
     * 新增用户
     * @param supplyShop 用户对象
     * @return 新增结果
     */
    @Override
    public int addSupplyShop(BtSupplyShop supplyShop) {
        supplyShop.setId(IdUtil.fastUUID());
        return supplyShopMapper.insert(supplyShop);
    }

    /**
     * 更新用户
     * @param supplyShop 用户对象
     * @return 更新结果
     */
    @Override
    public int updateSupplyShop(BtSupplyShop supplyShop) {
        return supplyShopMapper.updateById(supplyShop);
    }

    @Override
    public int deleteSupplyShop(String supplyShopId) {
        return supplyShopMapper.deleteById(supplyShopId);
    }

    // * =================================================基础增删改查END============================================== *
}
